<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head lang="en">
    <style>
	body{background: transparent;}
    </style>
    <meta charset="UTF-8">
 <base href="/res/en/" />
    <link type="text/css" rel="stylesheet" href="css/main_inner.css" />
</head>
<body>

<div class="mainArea_inner">
<!--
    <div class="header">
        <font style="size:19px;color:red">中国</font><p class="pageTitle fontDinproMedium">发布代码</p>
       </div>
    <div class="nav">
        <div class="curBg"></div>
        
    </div>
   
-->
<style>
  .mainArea_inner>.mainBody .selectorDiv{
        margin-top: 0;
    }
    .mainArea_inner>.mainBody .selectorDiv>.selectorName{
        line-height: 28px;
        float: left;
        padding-right: 6px;
        vertical-align: middle;
        font-size: 12px;
        color: #2e2e2e;
    }
    .mainArea_inner>.mainBody .selectorDiv>.selectorName>span{
        color: red;
    }
    .mainArea_inner>.mainBody .selectorDiv>.listGroup{
        float: left;
        width: 164px;
        height: 28px;
    }
    .mainArea_inner>.mainBody .selectorDiv>.listGroup>.btnLeft{
        width: 110px;
        font-size: 12px;
        color: #ffffff;
        text-align: left;
        padding-left: 20px;
        padding-right: 0px;
        margin-left: 0;
        border-right: 0;
        padding: 4px 5px 4px 15px;
    }
    .mainArea_inner>.mainBody .selectorDiv>.listGroup>.dropDownList{
        width: 163px;
    }
</style>

<div class="mainBody" style="overflow:auto;" >
	<div style="float:left">
       <?php echo form_open_multipart('deploy_online/add_task'); ?>
	<div class="btnArea floatFix">
		<div class="search noMarginTop fontDinpro">
			<input type="hidden" name='app' value=<?php echo $apps[$current_app];?> />
			<input type="hidden" name='env' value=<?php echo $envs[$current_env];?> />
			<input type="hidden" name='class' value=<?php echo $classs[$current_class];?> />
			<label for="start">分类：</label>
		    		<div class="selectorDiv">
					<div class="locationGroup listGroupDown listGroup">
					<a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
					    <?php
						    echo $classs[$current_class];
					    ?>
					</a>
					<a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
					<ul class="dropDownList fontDinpro">
					<?php foreach($classs as $k => $v): ?>
					<li>
					    <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url("/deploy_online/view/$current_app/$current_env/$k"); ?>"> <?php echo $v; ?></a>
					</li>
					<?php endforeach; ?>
					</ul>
					</div>
				</div>
		</div>

		<div class="search noMarginTop fontDinpro">
			<label for="start">应用：</label>
			<div class="selectorDiv">
				<div class="locationGroup listGroupDown listGroup">
				<a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
				    <?php
					    echo $apps[$current_app];
				    ?>
				</a>
				<a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
				<ul class="dropDownList fontDinpro">
				    <?php foreach($apps as $k => $v): ?>
					<li>
					    <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url("/deploy_online/view/$k/$current_env/$current_class"); ?>"> <?php echo $v; ?></a>
					</li>
				    <?php endforeach; ?>
				</ul>
				</div>
			</div>
		</div>
            
            	<div class="search noMarginTop fontDinpro">
                	<label for="start">环境：</label>
				<div class="selectorDiv">
			    <div class="locationGroup listGroupDown listGroup">
				<a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
				    <?php
					    echo $envs[$current_env];
				    ?>
				</a>
				<a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
				<ul class="dropDownList fontDinpro">
				    <?php foreach($envs as $k => $v): ?>
					<li>
					    <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url("/deploy_online/view/$current_app/$k/$current_class"); ?>"><?php echo $v; ?></a>
					</li>
				    <?php endforeach; ?>
				</ul>
			    </div>
        	</div>
        </div>
	    <div class="deploybtn noMarginTop fontDinpro">
			<button class="btn searchBtn" href="javascript:void(0)" style='float:left; top: 0px; position: absolute;' type='submit'>发布</button>
	    </div>
       <?php echo form_close(); ?>
	</div>
</div>
    	<div style="float:left" class="rollbackbtn noMarginTop fontDinpro">
	<button class="btn searchBtn" style='float:left; top: 0px; position: absolute;' onclick="location.href='<?php echo backend_url("/deploy_online/rollback/$apps[$current_app]/$envs[$current_env]");?>'">回滚</button>
    	</div>
    <div class="tableContent">
        <table class="fontDinpro">
            <thead>
            <tr>
                <th style="width: 6%;">任务ID</th>
                <th style="width: 10%;">应用名</th>
                <th style="width: 5%;">环境</th>
                <th style="width: 5%;">进度</th>
                <th style="width: 5%;">提交者</th>
                <th style="width: 10%;">提交时间</th>
                <th style="width: 5%;">回滚版本</th>
                <th style="width: 5%;">发布过程</th>
                <td style="width: 5%;">更新内容</td>
                <td style="width: 5%;">删除</td>
            </tr>
            </thead>
            <tbody>
             <tr>
                <th style="width: 6%;">任务ID</th>
                <th style="width: 10%;">应用名</th>
                <th style="width: 5%;">环境</th>
                <th style="width: 5%;">进度</th>
                <th style="width: 5%;">提交者</th>
                <th style="width: 10%;">提交时间</th>
                <th style="width: 5%;">回滚版本</th>
                <th style="width: 5%;">发布过程</th>
                <td style="width: 5%;">更新内容</td>
                <td style="width: 5%;">删除</td>
            </tr>
            <?php foreach($list as $v) : ?>
                <tr class="lowTr">
                	<td><?php echo $v['id'];?></td>
                   
                   	<td>
                        <?php $app_name= $this->app_info_model->get_app_name($v['appid']);echo $app_name;?>
                   	</td>
                   	<td>
                        <?php echo $v['env'];?>
                   	</td>
                    <td>
                    <?php switch($v['status']){
                    	case 0:
                    		echo '<span class="colorLabel bgBlue" style="display: inline-flex;">等待开始</span>';
                    		break;
                    	case 1:
                    		echo '<span class="colorLabel bgOrange" style="display: inline-flex;">进行中</span>';
                    		break;
                    	case 2:
                    		echo '<span class="colorLabel bgGreen" style="display: inline-flex;">完成</span>';
                    		break;
                    	case 3:
                    		echo '<span class="colorLabel bgBlack" style="display: inline-flex;">暂停</span>';
                    		break;
                    	default:
                    		echo '<span class="colorLabel bgRed" style="display: inline-flex;">参数不够</span>';
                    		break;
                    } ?></td>
                   <td><?php echo $v['deploy_user'];?></td>
                   <td><?php echo date('y-m-d H:i:s',$v['date']); ?></td>
                   <td><?php if($v['back_commit']=="null") echo "latest";else echo $v['back_commit'];?></td>
		   <td>
			<a href="javascript:void(0)">
			<button class="tableBtn" onclick="location.href='<?php echo backend_url("/deploy_online/deploying/$app_name"); ?>'">
                                查看
                        </button>
                        </a>
		   </td>
                   <td>
                        <a href="javascript:void(0)" title="<?php echo $app_name."的最近5次提交:\n";
				$commit_log = $this->commit_log_model->get_commit_log($app_name,$v['env']);
				if(count($commit_log)!=0){
					foreach($commit_log as $key => $value)
					{
						//if(count($v) == 0) echo "NULL";continue;
						echo $value['last_commit_time']."==>".$value['last_commit']."\n";
					} 
				}else{
					echo "null";
				}
				?>">
                   	<button class="tableBtn" onclick="location.href='<?php echo backend_url("/deploy_online/update_content/".$app_name); ?>'">
				查看
                        </button>
			</a>
                   </td>
                   <td>
                   	<button class="tableBtn" onclick="beSureDelete('','<?php echo backend_url("/deploy_online/del/".$v['id']); ?>')">
                        <div class="delIcon"></div>Delete
                        </button>
                   </td>
                </tr>
            <?php endforeach; ?>
            <tr style="height: 33px;"></tr>
            </tbody>
        </table>
    </div>

</div>


    
    <div class="shadow"></div>
</div>
<div class="popUpImg"></div>

</body>
</html>
